package top.minuy.structure.graph.representations;

/**
 * 带权边
 *
 * @author Minuy
 * @time 16:17
 * @date 2021/11/25
 */
public class WeightedEdge implements Comparable<WeightedEdge>{
    public int v; // 顶点1
    public int w; // 顶点2
    public int weight; // 权值

    public WeightedEdge(int v, int w, int weight) {
        this.v = v;
        this.w = w;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return  String.format("{%d-%d:%d}",v,w,weight);
    }

    /**
     * 可比较的接口，只比较权值
    * @param weightedEdge 比较的对象
      * @return int 比较的结果
     * @author Minuy
     * @date 2021/11/25 16:16
     */
    @Override
    public int compareTo(WeightedEdge weightedEdge) {
        return this.weight-weightedEdge.weight;
    }
}
